package com.love.travel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.love.common.log.annotation.Log;
import com.love.common.log.enums.BusinessType;
import com.love.common.security.annotation.RequiresPermissions;
import com.love.travel.domain.TravelItineraryAttraction;
import com.love.travel.service.ITravelItineraryAttractionService;
import com.love.common.core.web.controller.BaseController;
import com.love.common.core.web.domain.AjaxResult;
import com.love.common.core.utils.poi.ExcelUtil;
import com.love.common.core.web.page.TableDataInfo;

/**
 * 行程-景点关联Controller
 * 
 * @author love
 * @date 2025-10-24
 */
@RestController
@RequestMapping("/itineraryAttraction")
public class TravelItineraryAttractionController extends BaseController
{
    @Autowired
    private ITravelItineraryAttractionService travelItineraryAttractionService;

    /**
     * 查询行程-景点关联列表
     */
    @RequiresPermissions("travel:itineraryAttraction:list")
    @GetMapping("/list")
    public TableDataInfo list(TravelItineraryAttraction travelItineraryAttraction)
    {
        startPage();
        List<TravelItineraryAttraction> list = travelItineraryAttractionService.selectTravelItineraryAttractionList(travelItineraryAttraction);
        return getDataTable(list);
    }

    /**
     * 导出行程-景点关联列表
     */
    @RequiresPermissions("travel:itineraryAttraction:export")
    @Log(title = "行程-景点关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TravelItineraryAttraction travelItineraryAttraction)
    {
        List<TravelItineraryAttraction> list = travelItineraryAttractionService.selectTravelItineraryAttractionList(travelItineraryAttraction);
        ExcelUtil<TravelItineraryAttraction> util = new ExcelUtil<TravelItineraryAttraction>(TravelItineraryAttraction.class);
        util.exportExcel(response, list, "行程-景点关联数据");
    }

    /**
     * 获取行程-景点关联详细信息
     */
    @RequiresPermissions("travel:itineraryAttraction:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(travelItineraryAttractionService.selectTravelItineraryAttractionById(id));
    }

    /**
     * 新增行程-景点关联
     */
    @RequiresPermissions("travel:itineraryAttraction:add")
    @Log(title = "行程-景点关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TravelItineraryAttraction travelItineraryAttraction)
    {
        return toAjax(travelItineraryAttractionService.insertTravelItineraryAttraction(travelItineraryAttraction));
    }

    /**
     * 修改行程-景点关联
     */
    @RequiresPermissions("travel:itineraryAttraction:edit")
    @Log(title = "行程-景点关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelItineraryAttraction travelItineraryAttraction)
    {
        return toAjax(travelItineraryAttractionService.updateTravelItineraryAttraction(travelItineraryAttraction));
    }

    /**
     * 删除行程-景点关联
     */
    @RequiresPermissions("travel:itineraryAttraction:remove")
    @Log(title = "行程-景点关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(travelItineraryAttractionService.deleteTravelItineraryAttractionByIds(ids));
    }
}
